﻿<Application x:Class="DTC.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources/ButtonsStyles.xaml"/>
                <ResourceDictionary Source="Resources/Brushes.xaml"/>
                <ResourceDictionary Source="Resources/BorderStyles.xaml"/>
                <ResourceDictionary Source="Resources/ToolTipStyles.xaml"/>
                <ResourceDictionary Source="Resources/TreeViewStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="PopupBorder" TargetType="{x:Type Border}">
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="Gray" />
                <Setter Property="Background" Value="{StaticResource WindowBorderBrushBackground}" />
                <Setter Property="CornerRadius" Value="10,10,17,17"/>
            </Style>
            <Style x:Key="PopupGridStyle" TargetType="{x:Type Grid}">
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
            </Style>
            <Style x:Key="PopupColumnStyle" TargetType="{x:Type ColumnDefinition}">
                <Setter Property="Width" Value="*"/>
            </Style>
            <Style x:Key="PopupTopRowStyle" TargetType="{x:Type RowDefinition}">
                <Setter Property="Height" Value="21"/>
            </Style>
            <Style x:Key="PopupMiddleRowStyle" TargetType="{x:Type RowDefinition}">
                <Setter Property="Height" Value="*"/>
            </Style>
            <Style x:Key="PopupBottomRowStyle" TargetType="{x:Type RowDefinition}">
                <Setter Property="Height" Value="33"/>
            </Style>

            <Style x:Key="PopupWindow" TargetType="{x:Type Window}">
                <Setter Property="AllowsTransparency" Value="True" />
                <Setter Property="WindowStyle" Value="None" />
                <Setter Property="Background" Value="{StaticResource WindowBackground}" />
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="ShowInTaskbar" Value="False"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Window}">
                            <Border>
                            <Border Style="{StaticResource PopupBorder}" Margin="30">
								<Border.BitmapEffect>
									<DropShadowBitmapEffect Color="Black" Opacity="0.6" Direction="320" ShadowDepth="0.5" Softness="1"/>
								</Border.BitmapEffect>
                                <Grid Style="{StaticResource PopupGridStyle}" Margin="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Style="{StaticResource PopupColumnStyle}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Style="{StaticResource PopupTopRowStyle}"/>
                                        <RowDefinition Style="{StaticResource PopupMiddleRowStyle}"/>
                                        <RowDefinition Style="{StaticResource PopupBottomRowStyle}"/>
                                    </Grid.RowDefinitions>
                                        <Grid MouseLeftButtonDown="StackPanel_MouseLeftButtonDown"  Grid.Row="0" Margin="0" HorizontalAlignment="Stretch">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="17"/>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="17"/>
                                            </Grid.ColumnDefinitions>
                                            
                                            <Border Opacity="1" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="0,0,1,1"/>
                                            <TextBlock Grid.Column="1" Width="Auto"
												HorizontalAlignment="Center" 
												Background="Transparent" 
												Text="{TemplateBinding Title}"
												Foreground="Black"
												FontSize="12"
												FontWeight="Bold"/>
                                            <Button Grid.Column="2" 
												x:Name="CloseButton" 
												Style="{StaticResource CloseControlButton}"
												Width="14" Height="11" Margin="0,0,4,4" 
												HorizontalAlignment="Right" 
												VerticalAlignment="Top" 
												BorderBrush="Red" 
												Click="CloseButton_Click">
                                                <Grid Margin="2,1,3,2">
                                                    <Path VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FFFFFFFF" Data="M 0,0 L1,1" StrokeThickness="2"/>
                                                    <Path VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#FFFF0000" Stretch="Fill" Stroke="#FFFFFFFF" Data="M 0,1 L1,0" StrokeThickness="2"/>
                                                </Grid>
                                            </Button>
                                        </Grid>
                                    <Border BorderThickness="1" CornerRadius="6" Margin="4" Grid.Row="1"
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{StaticResource WindowsContentBorderBrush}">
                                            <AdornerDecorator>
                                                <ContentPresenter IsHitTestVisible="True" 
                                                          HorizontalAlignment="Stretch" 
                                                          VerticalAlignment="Stretch" 
                                                          Focusable="True"/>
                                            </AdornerDecorator>
                                        </Border>
                                        <Grid Grid.Row="2" Margin="3,0,3,0">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="0.5*"/>
                                                <ColumnDefinition Width="0.5*"/>
                                            </Grid.ColumnDefinitions>
                                            <Button x:Name="AcceptBtn" 
												Style="{StaticResource AcceptButton}" 
												Grid.Column="0" Height="23" 
												Margin="2,1,3,0"
												Click="AcceptBtn_Click" 
												FontSize="12" FontWeight="Bold" 
												VerticalAlignment="Top">Принять</Button>
                                            <Button x:Name="CancelBtn" 
												Style="{StaticResource CancelButton}" 
												Grid.Column="1" Height="23" 
												Margin="3,1,2,0"
												Click="CloseButton_Click" 
												FontSize="12" FontWeight="Bold" 
												VerticalAlignment="Top">Отменить</Button>
                                        </Grid>
                                </Grid>
                            </Border>
							</Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="{x:Type Control}">
                <Setter Property="Focusable" Value="False"/>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>
